package br.com.millenium.service.equipe.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import com.restfb.json.JsonObject;

import br.com.millenium.domain.manager.BuscarFilialManager;
import br.com.millenium.domain.manager.IBuscarFilialManager;
import lumis.portal.PortalException;
import lumis.portal.controller.ControllerException;
import lumis.portal.controller.ControllerHtml;
import lumis.portal.manager.ManagerFactory;

public class BuscarFilialController extends ControllerHtml
{

	public BuscarFilialController(HttpServletRequest request, HttpServletResponse response) throws ControllerException,PortalException
	{
		super(request, response);
	}
	
	public void handllerRequest() throws Exception
	{
		response.setContentType("application/json");
		
		String bandeiraId = request.getParameter("band");
		
		BuscarFilialManager dem = new BuscarFilialManager();
		
		JSONArray filiais = dem.listaFilial(bandeiraId, sessionConfig);
		
		response.getWriter().print(filiais.toJSONString());
	}
	
	public void sessionManager()
	{
		String save = request.getParameter("save");
		
		if(save == "true")
			sessionSave();
		else
			sessionBring();
	}
	
	public void sessionSave()
	{
		String filialSelected = request.getParameter("filialSelected");
		
		request.getSession().setAttribute("filialSelected", filialSelected);
	}
	
	public void sessionBring(){}

}
